package edu.hawaii.myisern.model;

/**
 * Represents a user of the MyISERN system.  This class was adapted from the Bugzooky example.
 * 
 * @author Tim Fennell
 * @author Laura Matsuo
 *
 */
public class User {
    private String username;
    private String password;

    /**
     * Default constructor.
     */
    public User() {
      //empty constructor.
    }

    /**
     * Constructs a well formed person.
     * 
     * @param username  The user's username.
     * @param password  The user's password.
     */
    public User(String username, String password) {
      this.username = username;
      this.password = password;
    }

    /**
     * Gets the user's username.
     * 
     * @return  The user's username.
     */
    public String getUsername() {
      return username; 
    }

    /**
     * Sets the user's username.
     * 
     * @param username  The user's username.
     */
    public void setUsername(String username) {
      this.username = username; 
    }

    /**
     * Gets the user's password.
     * 
     * @return  The user's password.
     */
    public String getPassword() {
      return password;
    }

    /**
     * Sets the user's password.
     * 
     * @param password  The user's password.
     */
    public void setPassword(String password) {
      this.password = password;
    }

    /**
     * Equality is determined to be when the usernames match.
     * 
     * @param obj  The object to compare this user to.
     * @return     True if obj is equal to the user, otherwise false.
     */
    @Override 
    public boolean equals(Object obj) {
      if ((obj instanceof User) && (this.username.equals(((User) obj).username))) {
        return true;
      }
      return false;
    }

    /** 
     * The hashcode of the user is the same as the hashcode of the user's username.
     * 
     * @return  The user's hashcode.
     */
    @Override
    public int hashCode() {
      return this.username.hashCode();
    }

}
